<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
		<title>购物车</title>
		<link rel="stylesheet" href="$!rc.contextPath/common/common.css" />
		<link rel="stylesheet" href="$!rc.contextPath/css/shopping_cart_reset.css" />
		<link rel="stylesheet" type="text/css" href="$!rc.contextPath/css/shopping_cart.css"/>
	</head>
	<body>
		<!--头部-->
	    <div class="title text-center">
			<a onClick="javascript:window.history.go(-1)"><</a>
			购物车
			<span class="fr write" onclick="f_del();">删除</span>
		</div>
	    <!--头部-->
	    <!--主题-->
	    <div class="no">
	    	<a href="http://wec.wukongsm.com/" class="link"></a>
	    	<p>暂无商品 ，快去逛逛吧！</p>
	    </div>
	    #if ($!cnt > 0)
	    <div class="con">	
		    <div class="content">
		    	<div class="list">
		    		<div class="fl">
		    			<label>
			    			<input type="checkbox"/>
			    			<img src="$!rc.contextPath/img/c_checkbox_off.png"/>
			    		</label>
		    		</div>
		    		<p>共$!cnt件商品</p>
		    	</div>
			    <ul ind="0" id="sk">
			    	#foreach($sku in $list)
			    	<li class="">
			    		<div class="label fl">
			    			<label>
				    			<input type="checkbox" value="$!sku.osc_detail_id"/>
				    			<img src="$!rc.contextPath/img/c_checkbox_off.png"/>
				    		</label>
			    		</div>
			    		<div class="img fl" onclick="window.location.href='$!rc.contextPath/skuView/detail?skuId=$!sku.sku_id'">
			    			<img src="http://app.tmaipay.com/$!sku.attach_path"/>
			    		</div>
			    		<div class="text fl" >
			    			<div onclick="window.location.href='$!rc.contextPath/skuView/detail?skuId=$!sku.sku_id'">
			    				<p class="overflow">$!sku.sku_name</p>
			    			</div>
			    			
			    			<p class="clearfix">
			    				<span class="fl red" onclick="window.location.href='$!rc.contextPath/skuView/detail?skuId=$!sku.sku_id'">￥ $!sku.sku_price</span>
			    				<span class="fr co">
			    					<input type="button" value="-" class="btn1" />
			    					<span class="number" val="$!sku.osc_detail_id">$!sku.sku_amount</span>
			    					<input type="button" value="+"  class="btn2"/>
			    				</span>
			    			</p>
			    		</div>
			    	</li>
			    	#end
			    </ul>
			    <p class="total"><number></number><span></span></p>
		    </div>
	    </div>
	    #end
	    <!--主题-->
	    <!--结算-->
	    <div class="bottom fixed">
	    	<div class="fl bottom-label">
	    		<label>
	    			<input type="checkbox"/>
	    			<img src="$!rc.contextPath/img/c_checkbox_off.png" class="fl" />
	    			全选
	    		</label>
	    	</div>
    		<div class="fr">
    			需要支付：<a class="red">￥</a><span class="red" id="payMoney"></span>
    			<button class="sett" onclick="f_pay()">结算</button>
    		</div>
	    </div>
	     <!--结算-->
	     <!--删除-->	
		<!-- <div class="confirm">
			<p class="confirm-title">你确定要删除该订单么?</p>
			<div>
				<div class="delete yes">确定</div>
				<div class="cancle">取消</div>
			</div>
		</div> -->
	     <!--删除-->
	     <!--弹框-->
	    <div class="text1 fixed">
	    	<form onsubmit="return false;">
	    		<input type="number"/>
	    		<input type="button"  value="确定"/>
	    	</form>
	    </div>
	     <!--弹框-->
	    <!--弹框2-->
	    <div class="alert fixed"></div>
	    <a href="http://app.wukongsm.com/entrance" class="link-wukong"></a>
	    <div id="ajaxNav">
	    	#parse("index-tab.html")
	    </div>
		<script src="$!rc.contextPath/js/web.js"></script>
		<script src="$!rc.contextPath/js/zepto.js"></script>
		<script src="$!rc.contextPath/js/shopping_cart.js"></script>
		<script type="text/javascript">
		var ids = "";
		$(function(){
			$(".nav-tabbar__item").eq(2).addClass("nav-tabbar__item--on");
			
		});
		
		function f_pay(){
			ids = "";
			$.each($('li'), function() {
				if($(this).find("input[type=checkbox]").attr("checked")=="checked") {
					ids += $(this).find("input[type=checkbox]").attr("value")+ ",";
				}
			});
			
			var payMoney = $("#payMoney").text();
			
			if(ids != ""){
				window.location.href = '$!rc.contextPath/shopCartPay?ids=' + ids + "&payMoney=" + payMoney;
			}
			
		}
		
		function f_del(){
			ids = "";
			$.each($('li'), function() {
				if($(this).find("input[type=checkbox]").attr("checked")=="checked") {
					ids += $(this).find("input[type=checkbox]").attr("value")+ ",";
				}
			});
			
			if(ids != ""){
				$.ajax({
	                type: 'POST',
	                url: '$!rc.contextPath/sku/delShopCartDetail',
	                data : {
	                	ids : ids
	                },
	                dataType: 'json',
	                success: function(data){
	                	console.log(data);
	                	
	                	if(data.code == '0'){
	                		$.each($('li'), function() {
		                		if ($(this).find("input[type=checkbox]").attr("checked")=="checked") {
		                			$(this).remove();
		                		}
		                	});
		                	$.each($(".content"), function() {
		                		if ($(this).find("li").length==0) {
		                			$(this).remove();
		                		}
		                	});
		                	hide();
		                	total();
		                	$(".confirm").css("bottom",-170+"px");
	                	}else{
	                		alert(data.text);
	                	}
	                }
	            });
			}else{
				return false;
			}
		}
		
		function f_edit(cnt, id){
			$.ajax({
                type: 'POST',
                url: '$!rc.contextPath/sku/updateShopCartDetail',
                data : {
                	cnt : cnt,
                	id : id
                },
                dataType: 'json',
                success: function(data){
                	console.log(data);
                	
                	if(data.code != '0'){
                		alert(data.text);
                	}
                }
            });
		}
		</script>
	</body>
</html>
